;+
; NAME: 
;       IRDC_LOOKUP
;
; PURPOSE: 
;       Look up where there is an IRDC at a given BGPS source.
;
; CALLING SEQUENCE:
;       flag = IRDC_LOOKUP(glon, glat)
;
; INPUTS:
;       GLON, GLAT -- Galactic Longitude and Latitude in decimal degrees.
;
;
; KEYWORD PARAMETERS:
;
;
;
; OUTPUTS:
;       FLAG = binary flag indicating the presence of an IRDC along an LOS
;
;
; MODIFICATION HISTORY:
;
;       Tue Oct 20 11:16:39 2009, Erik Rosolowsky <erosolo@A302357>
;		Written
;       Modified: 02/15/11, TPEB -- Updated to work with the new
;                                   IRDC_FULL_DATA.sav version of the
;                                   Peretto & Fuller (2009) catalog
;                                   and definitions.
;
;-

FUNCTION IRDC_LOOKUP, l, b
  
  restore, file = 'irdc_full_data.sav'
  
  gcirc, 2, l, b, pf_irdc.l, pf_irdc.b, dist
  min_dist = min(dist, hit)
  posang, 1, l, b, pf_irdc[hit].l, pf_irdc[hit].b, pahit
  major_proj = dist[hit]*cos((pahit-pf_irdc[hit].pa_irdc)*!dtor)
  minor_proj = dist[hit]*sin((pahit-pf_irdc[hit].pa_irdc)*!dtor)
  
  dist = sqrt((major_proj/p_irdc[hit].maj)^2+(minor_proj/pf_irdc[hit].min)^2)
  
  RETURN, (dist LE 1)
END
